package com.bi.autotest.pages.payprocesspage;

import com.auto.base.PageAppium;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

public class NewMyLoginPage extends PageAppium {
    public final String IS_LOGIN_PAGE_TEXT = "《用户/商户服务条款》";
    public final String PHONENUMBER_XP = "//*[@name='phoneNumber']";
    public final String VERIFYCODE_XP = "//*[@name='verifyCode']";
    public final String PASSWORD_AREA_TEXT = "输入验证码";
    public final String LOGIN_BUTTON_XP = "//*[@id='btnAuth']";
    public final String AGREE_XP = "//android.view.View[@content-desc=' 我已阅读并同意']";
    public final String TO_LOGIN_BUTTON_XP = "//div[@class=\"notLoggedIn\"]/following-sibling::a";
    public final String TO_LOGIN_SUCCESSPAGE = "登录并收款";//
    public final String CONFIRM_LOGIN_ID = "//*[@id=\"sellerLogin\"]";//确认登录
    public final String ISCACHE_SUCCESSPAGE = "设置金额";//缓存登录关键字
    public final String GG_BUTTON_SELECT_XP = "//android.view.View[@content-desc='故宫']";
    public final String RECEIVABLES_CODE_XP = "//android.widget.TextView[@text='https://msdev.188yd.com/wxh/seller/qrcodeByStore']";//微信收藏_收款码xpath
    public final String STORE_HYD_XP = "//*[@data-id='1']";//好又多门店

    public NewMyLoginPage(AndroidDriver androidDriver) {
        super(androidDriver);
    }

    /**
     * 获取收藏收款码链接控件
     *
     * @return
     */
    public AndroidElement getReceivablesCode() {
        return waitAutoByXp(RECEIVABLES_CODE_XP);
    }

    /**
     * 获取登录并收款的按钮
     *
     * @return
     */
    public AndroidElement getToLoginButton() {
        return waitAutoByXp(TO_LOGIN_BUTTON_XP, 5);
    }

    /**
     * 判断是否是登录界面
     *
     * @return
     */
    public boolean isLoginPage() {
        return isTextElementExist(IS_LOGIN_PAGE_TEXT, 5);
    }

    /**
     * 获取登陆的按钮
     *
     * @return
     */
    public AndroidElement getLoginButton() {
        return waitAutoByXp(LOGIN_BUTTON_XP);
    }

    /**
     * 获取选择门店时登陆的按钮
     *
     * @return
     */
    public AndroidElement getConfirmLoginButton() {
        return waitAutoByXp(CONFIRM_LOGIN_ID);
    }

    /**
     * 获取输入手机号的输入框H5
     */
    public AndroidElement getNameInputAreaH5() {
        return waitAutoByXp(PHONENUMBER_XP);
    }

    /**
     * 获取输入验证码的输入框H5
     */
    public AndroidElement getPassWordInputAreaH5() {
        return waitAutoByXp(VERIFYCODE_XP);
    }

    /**
     * 获取选择门店时故宫的按钮
     */
    public AndroidElement getGGButton() {
        return waitAutoByXp(GG_BUTTON_SELECT_XP);
    }


    /**
     * 获取阅读并同意的文字  用来选择同意的对勾
     */
    public AndroidElement getAgreeArea() {
        return waitAutoByXp(AGREE_XP);
    }

    /**
     * 是否登陆成功的验证  设置为等待5s时间查找控件
     */
    public boolean isLoginSuccess() {
        return isXpathExist(CONFIRM_LOGIN_ID, 5);
    }

    /**
     * 判断是不是有缓存直接登陆成功的页面
     */
    public boolean isCacheLoginSuccessPage() {
        return isTextElementExist(ISCACHE_SUCCESSPAGE, 5);
    }

    public AndroidElement getStoreHYD() {
        return waitAutoByXp(STORE_HYD_XP, 5);
    }

    public AndroidElement getSellerLogin() {
        return waitAutoByXp(CONFIRM_LOGIN_ID, 5);
    }
}
